#!/usr/bin/python
# encoding: utf-8
import MySQLdb

host = "10.0.11.142"
username = "yongche"
password = "yongche"
dbname = "yc_car_master_stat"

def inserData(table, imei, system, statTime):
    db = MySQLdb.connect(host, username, password, dbname)
    cursor = db.cursor()
    sql = "INSERT INTO %s(imei, system, stat_time) VALUES ('%s', '%d', '%s')" % (table, imei, system, statTime)

    try:
#        print sql
        cursor.execute(sql)
        db.commit()
    except Exception, e:
        print "inset error", e
        db.rollback()
    db.close()

def insertUAcnt(imei, visitCnt, statTime):
    db = MySQLdb.connect(host, username, password, dbname)
    cursor = db.cursor()
    sql = "INSERT INTO user_agent_device_cnt(imei, visit_count, stat_time) VALUES ('%s', '%d', '%s')" % (imei, visitCnt, statTime)

    try:
#        print sql
        cursor.execute(sql)
        db.commit()
    except Exception, e:
        print "inset error", e
        db.rollback()
    db.close()

def test():
    print "Hello world!";
